// 图解地址 https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/solution/shuang-zhi-zhen-shan-chu-zhong-fu-xiang-by-t9qx90n/
// 思考  1题目中约定数组为排好序的数组
//       2题目中规定不使用额外空间，即不改变数组nums的指针


/**
 * @param {number[]} nums
 * @return {number}
 */
var removeDuplicates = function (nums) {
    if (nums.length < 2) return 
    var i = 0;
    for (var j = 1; j < nums.length; j++) {
        if (nums[i] != nums[j]) nums[++i] = nums[j]
    }
    nums.length = i + 1
};
// var attr = [0, 0, 1, 1, 2, 2, 3, 3, 4, 5, 5, 5, 5, 5, 6, 6]
var attr = [0]
removeDuplicates(attr)
console.log(attr)